<!doctype html>
<html lang="zh-cn">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="__public__/static/css/normalize.css">
    <link rel="stylesheet" href="__public__/admin/css/style.css">
    <script src="__public__/static/js/jquery-2.2.0.min.js"></script>
    <title>数字串串乐活动管理</title>

</head>
<body style="background-color:#fff">
<section class="warps">
    <div id="test">
        <a href="javascript:;" switch="off">1</a>
        <a href="javascript:;" switch="off">2</a>
        <a href="javascript:;" switch="off">3</a>
        <a href="javascript:;" switch="off">4</a>
        <a href="javascript:;" switch="off">5</a>
        <a href="javascript:;" switch="off">6</a>
        <a href="javascript:;" switch="off">7</a>
        <a href="javascript:;" switch="off">8</a>
        <a href="javascript:;" switch="off">9</a>
        <a href="javascript:;" switch="off">10</a>
        <a href="javascript:;" switch="off">11</a>
        <a href="javascript:;" switch="off">12</a>
        <a href="javascript:;" switch="off">13</a>
        <a href="javascript:;" switch="off">14</a>
        <a href="javascript:;" switch="off">15</a>
        <a href="javascript:;" switch="off">16</a>
        <a href="javascript:;" switch="off">17</a>
        <a href="javascript:;" switch="off">18</a>
        <a href="javascript:;" switch="off">19</a>
        <a href="javascript:;" switch="off">20</a>
        <a href="javascript:;" switch="off">21</a>
        <a href="javascript:;" switch="off">22</a>
        <a href="javascript:;" switch="off">23</a>
        <a href="javascript:;" switch="off">24</a>
        <a href="javascript:;" switch="off">25</a>
    </div>
</section>
<div class="hright"></div>
<a href="javascript:;" class="loginout">关闭活动</a>

<script>
    // var URL = 'http://youxi.cc:9908/index.php/';
    var URL = 'http://strong.4kb.cn/index.php/';
    var oDiv = document.getElementById('test');
    var oA = oDiv.getElementsByTagName('a');
    for (let i = 0; i < oA.length; i++) {
        oA[i].onclick = function () {

            if (oA[i].getAttribute('switch') == 'off') {
                this.className = 'active';
                oA[i].setAttribute('switch', 'on');
                $.ajax({
                    type: 'POST',
                    url: URL + 'admin/index/ajaxnum',
                    data: {id: i + 1},
                    dataType: "json",
                    success: function (data) {
                        console.log(data);
                    }
                });

            } else if (oA[i].getAttribute('switch') == 'on') {
                var msg = "您真的确定要取消数字" + (i + 1) + "？\n请确认！";
                if (confirm(msg) == true) {
                    oA[i].className = '';
                    oA[i].setAttribute('switch', 'off');
                    $.ajax({
                        type: 'POST',
                        url: URL + 'admin/index/ajaxnumno',
                        data: {id: i + 1},
                        dataType: "json",
                        success: function (data) {
                            if (data == 2) {
                                alert('已经取消');
                            }
                        }
                    });

                } else {
                    return false;
                }

            }

        }
    }

    $('.loginout').click(function () {
        var r=confirm("确定要退出活动？")
        if (r==true) {
            window.location.href="{:url('login/loginout')}";
        }else {
            return false;
        }
    })



</script>

</body>
</html>